@extends('d.layout.index')
@section('con')
<div class="mws-panel grid_8">
 	<div class="mws-panel-header">
     	<span>商品详细参数添加</span>
     </div>
     <div class="mws-panel-body no-padding">
     	<form class="mws-form" action="/admin/goods/updateparam" method="post" enctype="multipart/form-data">
               {{csrf_field()}}
               <input type="hidden" name="gid" value="{{$gid}}">
     		<div style="margin-left:400px;padding-top:10px;color:blue">
                    <label class="mws-form-label">商品参数</label>          
               </div>
               <div class="d" style="display:none">
                    <div class="mws-form-inline">
                         <div class="mws-form-row">
                              <label class="mws-form-label">参数名称</label>
                              <div class="mws-form-item">
                                   <input type="text" name='p0' class="small">
                              </div>
                         </div>                   
                    </div>
                    <div class="mws-form-inline">
                         <div class="mws-form-row">
                              <label class="mws-form-label">参数</label>
                              <div class="mws-form-item">
                                  <input type="text" name='p00' class="small">
                              </div>
                         </div>                   
                    </div>
               </div>
               @foreach($list as $k => $v) 
               <div class="d">
                    <div class="mws-form-inline">
                         <div class="mws-form-row">
                              <label class="mws-form-label">参数名称</label>
                              <div class="mws-form-item">
                                   <input type="text" name='name{{$k + 1}}' class="small" value="{{$v['name']}}">
                              </div>
                         </div>                   
                    </div>
                    <div class="mws-form-inline">
                         <div class="mws-form-row">
                              <label class="mws-form-label">参数</label>
                              <div class="mws-form-item">
                                  <input type="text" name='content{{$k + 1}}' class="small" value="{{$v['content']}}">
                              </div>
                         </div>                   
                    </div>
               </div>
               @endforeach
               <div class="mws-form-inline" id="s">
                    <div class="mws-form-row">
                         <button class="btn" id="btn" type="button">添加参数</button>
                    </div>
               </div>
     		<div class="mws-button-row">
     			<input type="submit" value="修改" class="btn btn-danger">
     			<input type="reset" value="重置" class="btn ">
     		</div>
     	</form>
     </div>    	
</div>
<script type="text/javascript" src="/d/js/libs/jquery-1.8.3.js"></script>
<script type="text/javascript">
     var num = $('input[class=small]:last').attr('name');
     num = Number(num.substr(-1,1)) + 1;
     $('#btn').click(function() {       
          var div = $('.d:first').clone();
          div.css('display','block');
          div.insertBefore($('#s'));
          div.find('input[name=p0]').attr('name','name'+num).val('');
          div.find('input[name=p00]').attr('name','content'+num).val('');
          num++;
          return false;
     });
</script>
@endsection